#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=60;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
char s[maxn],p[maxn];
LL n,m;
bool check(LL l1,LL r1,LL l2,LL r2){
    if( (r1-l1+1)!=(r2-l2+1) ) return false;
    LL j=l2;
    bool flag=1;
    for(LL i=l1;i<=r1;i++){
        if(s[i]==p[j]){
            j++;
        }
        else{
            return false;
        }
        if(j>r2) flag=0;
    }
    if(flag==0) return true;
    else return false;
}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
     memset(s,'\0',sizeof(s));memset(p,'\0',sizeof(p));
     cin>>(s+1);
     cin>>(p+1);
     n=strlen(s+1);
     m=strlen(p+1);
     LL ans=n+m;
     for(LL l1=1;l1<=n;l1++){
        for(LL r1=l1;r1<=n;r1++){
            for(LL l2=1;l2<=m;l2++){
                for(LL r2=l2;r2<=m;r2++){
                    if(check(l1,r1,l2,r2)==true){
                       ans=min(ans,n-(r1-l1+1)+m-(r2-l2+1));
                    }
                }
            }
        }
     }
     cout<<ans<<"\n";
  }

return 0;
}
